package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmChapterContentMapper;
import cn.mcartoon.pojo.MmChapterContent;
import cn.mcartoon.service.MmChapterContentService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmChapterContentServiceImpl implements MmChapterContentService {

    @Autowired
    private MmChapterContentMapper mmChapterContentMapper;

    public MmChapterContent getMmChapterContentById(Long id){
        return mmChapterContentMapper.getMmChapterContentById(id);
    }

    public List<MmChapterContent>	getMmChapterContentListByMap(Map<String,Object> param){
        return mmChapterContentMapper.getMmChapterContentListByMap(param);
    }

    public Integer getMmChapterContentCountByMap(Map<String,Object> param){
        return mmChapterContentMapper.getMmChapterContentCountByMap(param);
    }

    public Integer insertMmChapterContent(MmChapterContent mmChapterContent){
            return mmChapterContentMapper.insertMmChapterContent(mmChapterContent);
    }

    public Integer updateMmChapterContent(MmChapterContent mmChapterContent){
        return mmChapterContentMapper.updateMmChapterContent(mmChapterContent);
    }

    public Integer deleteMmChapterContentById(Long id){
        return mmChapterContentMapper.deleteMmChapterContentById(id);
    }

    public Integer batchDeleteMmChapterContent(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmChapterContentMapper.batchDeleteMmChapterContent(param);
    }

    public Page<MmChapterContent> queryMmChapterContentPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmChapterContentMapper.getMmChapterContentCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmChapterContent> mmChapterContentList = mmChapterContentMapper.getMmChapterContentListByMap(param);
        page.setList(mmChapterContentList);
        return page;
     }


}
